<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>宿舍管理系统</title>
    <meta name="renderer" content="webkit">
    <meta name="csrf-token" content="{{ csrf_token() }}"/>

    <link rel="stylesheet" href="{{asset('lib/layui/css/layui.css')}}">
    <script src="{{asset('lib/layui/layui.js')}}" charset="utf-8"></script>

</head>
<body>
{{--<div  class="layui-col-md5 article-contents">--}}
    {{--<img id="headIcon" alt="" src="" style="height: 100px;width: auto;">--}}
    {{--<button type="button" class="layui-btn layui-btn-radius layui-btn-normal" id="changeHeadIcon">--}}
        {{--<i class="layui-icon">&#xe67c;</i>更改图像--}}
    {{--</button>--}}
{{--</div>--}}

<button id="changeHeadIcon">XX</button>
</body>
<script>
    layui.use(['upload'], function(){
        var upload = layui.upload;

        //图片上传
        var uploadInst = upload.render({
            elem: '#changeHeadIcon' //绑定元素
            ,url: '/update.do' //上传接口
            ,data: {id:1}
            ,before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#headIcon').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //上传完毕回调
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });

</script>
</html>